#ifndef GLO_ED_H
#define GLO_ED_H
//#include "/home/00292431309/Desktop/mpich-1.2.7p1/include/mpi.h"
//#include "/usr/lib/mpich/include/mpi.h"
#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
#include "types.h"


//USAGE: Application must implement all four methods below


//application's task initialization
int ED_Init(int argc, char *argv[], int rank, int neighc, int *neighv);
/*Params: 

IN:
1) argc and argv are params passed by command line to the application; 
2) rank means the number of the process in the MPI environment. Process are from 0 to N-1 where N means the number of processes used by MPI's comand -np; 
3) neighc means the number of neighbours specified by the file graph.txt;
4) neighv is the vector containing the neighbours of the node which were specified by graph.txt. If, for example, there are 4 processes and the graph.txt is:
	2
	0 1
        1 3 

so to process 1 neighc is 2 and neighv is {0,3}. 

OUT:
5) return: not used yet
*/



//application's task computation
int ED_Event(void *msg, int index_type, int sender, int *msgc, int **destv, void **msgv, int **index_type_msgv);
/*
When application needs to create a datatype using the functions in types.c the methods return an index which means a identifier of the type in the model 
Params:
IN:
1)msg means the message which has triggered the event. It's type is reffered by index_type, which is the position of the type of the message in the type vector
2) index_type is the index of the type of the message in the vector type
3) sender is the neighbour who sent the msg

OUT:
4)msgc is the number of messages generated by the event processing
5)destv is the destination vector which is a vector containing the neighbours of the node to which each message is destinated
6) msgv is the vector representing the messages destinated to neighbours
7) msglen_sendv is the vector of the sizes of the messages
8) index_type_msgv is the array containing the indexes of the types of the messages

9)return: 0 if the node is active
   1 if node has become inactive


*/

//application's task memory allocation
int ED_Msg_buff_allocate(int size, int neigh, void *buff);
/*Used to allocate memory to store incoming messages. 
Params:

IN:
1) size is the memory amount necessary to receive the message through the channel
2) neigh is the neighbour from which the message will be received

OUT:
3) buff is the pointer to be allocated
4) return: not used yet

*/




//application's task free method
int ED_Finalize();
/*Used in the end of the computation in order to release memory used in the application
Param:
1) return: not used yet

*/



#endif
